package com.example.backend.controller.admin;

import com.example.backend.common.api.R;
import com.example.backend.dto.EmailDTO;
import com.example.backend.service.EmailService;
import jakarta.validation.Valid;
import lombok.RequiredArgsConstructor;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

/**
 * 邮件控制器
 */
@RestController
@RequestMapping("/admin/email")
@RequiredArgsConstructor
public class EmailController {
    
    private final EmailService emailService;
    
    /**
     * 发送测试邮件
     */
    @PostMapping("/test")
//    @PreAuthorize("hasAuthority('system:email:send')")
    public R<Void> sendTestEmail(@RequestBody @Valid EmailDTO emailDTO) {
        emailService.sendSimpleMail(emailDTO.getTo(), emailDTO.getSubject(), emailDTO.getContent());
        return R.ok();
    }
} 